package com.woniu.config;

import com.woniu.util.MinioProp;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 李松桦
 * @data 2023/3/9 10:46
 */
@Configuration
@EnableConfigurationProperties(MinioProp.class)
public class MinioConfig {
    /*把连接属性类注入进来*/
    @Autowired
    private MinioProp minioProp;
    /*
    * 获取文件服务器连接属性，创建客户端*/
    @Bean
    public MinioClient minioClient() throws Exception {
        return MinioClient.builder().endpoint(minioProp.getEndpoint())
                .credentials(minioProp.getAccesskey(), minioProp.getSecretKey()).build();
    }
}
